package com.itheima.youdianda.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.youdianda.domain.YddCate;
import com.itheima.youdianda.dto.PageDto;
import com.itheima.youdianda.mapper.YddCateMapper;
import com.itheima.youdianda.service.YddCateService;
import org.springframework.stereotype.Service;

/**
 * @ClassName YddCateServiceImpl
 * @Description
 * @Author Young
 * @Date 2023/2/13
 * @Version 1.0
 */
@Service
public class YddCateServiceImpl extends ServiceImpl<YddCateMapper,YddCate> implements YddCateService {
    @Override
    public PageDto mypage(String page, String limit, String catename) {
        //将String转为int
        int i = Integer.parseInt(page);
        int i1 = Integer.parseInt(limit);
        Page<YddCate> ii1Page = new Page<>(i, i1);
        LambdaQueryWrapper<YddCate> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.like(catename!=null,YddCate::getCatename,catename);
        this.page(ii1Page,queryWrapper);
        PageDto<YddCate> objectPageDto = new PageDto<>();
        objectPageDto.setValue(ii1Page);
        return objectPageDto;
    }
}
